#pragma once
#ifndef IMAGE_H_
#define IMAGE_H_

#include "graphicsobject.h"

namespace EPOC
{
	/**
	* Image class, this class is used to contain and handle a texture. 
	* @remark You should not create instances of this class your self, but instead use the CreateImage() and DestroyImage() methods found in EpGraphicsManager
	*/
	class Image : public GraphicsObject
	{
	public:
		
		/**
		* Contructor
		* Resets all members to the default values
		*/
		Image();

		/**
		* Destructor
		* Calls Cleanup()
		* @see Cleanup()
		* */
		virtual ~Image();

		/**
		* Cleans up all relevant data
		* @see ~EpImage()
		*/
		virtual void Cleanup();

		/**
		* Initializes the image
		* @remark Most times you don't have to worry about calling this method since this is already done by the grapichs manager.
		* @param EpTexture pointer to the texture that should be used by the image
		* @param nRenderMode tells in wich render mode epoc is running
		* @return true if the update succeeded and false if it didn't
		*/
		virtual bool Initialize(Texture *pTexture/*, RENDER_MODE nRenderMode*/);

		/**
		* Sets the number of frames in total, the number of frames horizontal and the number of frames vertical that builds up the image.
		* @param nFrames number of frames in total
		* @param nFramesX number of frames horizontal
		* @param nFramesY number of frames vertical
		* @see GetFramesX()
		* @see GetFramesY()
		* @see GetFrames()
		*/
		inline void SetFrames(int nFrames, int nFramesX, int nFramesY) { m_nFrames = nFrames; m_nFramesX = nFramesX; m_nFramesY = nFramesY;}
		
		/**
		* Returns the number of frames that builds up the image horizontally (columns)
		* @return The number of frames horizontally
		* @see SetFrames()
		* @see GetFramesY()
		* @see GetFrames()
		*/
		inline int GetFramesX() { return m_nFramesX;}
		
		/**
		* Returns the number of frames that builds up the image vertically (rows)
		* @return The number of frames vertically
		* @see SetFrames()
		* @see GetFramesX()
		* @see GetFrames()
		*/
		inline int GetFramesY() { return m_nFramesY;}

		/**
		* Returns the number of frames that builds up the image in total
		* @return The number of frames in total
		* @see SetFrames()
		* @see GetFramesX()
		* @see GetFramesY()
		*/
		inline int GetFrames() { return m_nFrames;}
		
		/**
		* Sets the current frame of the image
		* @param nCurrentFrame The frame to set as current
		* @see GetCurrentFrame()
		*/
		inline void SetCurrentFrame(int nCurrentFrame) { m_nCurrentFrame = nCurrentFrame;}

		/**
		* Returns the current frame of the image
		* @return The current frame
		* @see SetCurrentFrame()
		*/
		inline int GetCurrentFrame() { return m_nCurrentFrame;}

		/**
		* Sets a flag that tells if the image should treat the texture as a whole or as a collection of subimages
		* @param bFramesEnabled Set to true or false
		* @see IsFramesEnabled()
		*/
		inline void SetFramesEnabled(bool bFramesEnabled) { m_bFramesEnabled = bFramesEnabled;}
		
		/**
		* Checks wether frames are used by the image or not
		* @return True if frames is enabled or false if frames is disabled
		* @see SetFramesEnabled()
		*/
		inline bool IsFramesEnabled(){ return m_bFramesEnabled;}

	protected:
		/**
		* Renders the image in SDL mode
		* @param pDestTexture The texture to render the image on (backbuffer)
		* @remark This method is called from the Render() method declared in EpGraphicsObject if EPOC is setup to render in SDL mode. 
		* @see RenderOGL()
		*/
		virtual void RenderSDL( TextureSDL* pDestTexture);

		/**
		* Renders the image in OpenGL mode
		* @param pDestTexture The texture to render the image on (backbuffer)
		* @remark This method is called from the Render() method declared in EpGraphicsObject if EPOC is setup to render in OpenGL mode. 
		* @see RenderSDL()
		*/
		virtual void RenderOGL( );

	protected:
		int m_nFrames;			///< The total number of frames that builds up this image (if the image is used without subframes this i set to 1)
		int m_nFramesX;			///< The number of horizontal frames (columns) that builds up this image (if the image is used without subframes this i set to 1)
		int m_nFramesY;			///< The number of vertical frames (rows) that builds up this image (if the image is used without subframes this i set to 1)
		int m_nCurrentFrame;	///< The current frame of this image (if the image is used without subframes this i set to 0)
		bool m_bFramesEnabled;	///< Flag indicating if frames are used by the image or not
	
	}; // class Image
}; // namespace EPOC

#endif